<?php
/**
 * Created by PhpStorm.
 * User: 86182
 * Date: 2020/6/26
 * Time: 17:39
 */

namespace App\Utils;


use phpDocumentor\Reflection\Types\False_;

class Factory
{
    //也可以写在配置文件中
    public static function smsClassType(){
        return [
            'ali'=>"App\Utils\sms\AliSms",
            'tencent'=>"App\Utils\sms\Tencent",
        ];
    }
    public static function getClass($type, $classes, $params=[], $isInstance= false){
        //分为两种 返回静态 返回非静态
        if(!array_key_exists($type, $classes)){
            return false;
        }
        $class = $classes[$type];
//        var_dump($class);exit;
        if($isInstance){
            return (new \ReflectionClass($class))->newInstanceArgs($params);
        }else{
            return $class;
        }
    }

}